﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace XNAGuiLib.Core.Data
{
    public class Texture
    {
        #region Public Field - Value
        private Texture2D _value = null;
        /// <summary>
        /// gets or sets the 'texture2D'-value of the Texture Objects
        /// </summary>
        public Texture2D Value
        {
            get
            {
                return _value;
            }
            set
            {
                _value = value;
            }
        }
        #endregion

        #region Public Field - Rectangle
        private Rectangle _rectangle = new Rectangle();
        /// <summary>
        /// gets or sets the destination rectangle to use on this texture.
        /// </summary>
        public Rectangle Rectangle
        {
            get
            {
                return _rectangle;
            }
            set
            {
                _rectangle = value;
            }
        }
        #endregion

        #region Public Field - ModulationColor
        private Color _modulationColor = Color.White;
        /// <summary>
        /// gets or sets the modulation color to use for this textpart
        /// </summary>
        public Color ModulationColor
        {
            get
            {
                return _modulationColor;
            }
            set
            {
                _modulationColor = value;
            }
        }
        #endregion



        #region Constructor - Texture(Texture2D value)
        /// <summary>
        /// Creates a new Texture object with the given Texture2D object and default rectangle and modulation color.
        /// </summary>
        /// <param name="value">Texture2D object to be drawn later on.</param>
        public Texture(Texture2D value)
        {
            _value = value;

            _rectangle = new Rectangle(0, 0, _value.Width, _value.Height);
        }
        #endregion 

        #region Constructor - Texture(Texture2D value, Vector2 relPos)
        /// <summary>
        /// Creates a new Texture object with the given Texture2D object and default modulation color.
        /// </summary>
        /// <param name="value">Texture2D object to be drawn later on.</param>
        /// <param name="relPos">the Vector2 on which the Texture2D is drawn.</param>
        public Texture(Texture2D value, Vector2 relPos)
        {
            _value = value;

            _rectangle = new Rectangle((int)relPos.X, (int)relPos.Y, _value.Width, _value.Height);
        }
        #endregion 

        #region Constructor - Texture(Texture2D value, Rectangle rectangle)
        /// <summary>
        /// Creates a new Texture object with the given Texture2D object and default modulation color.
        /// </summary>
        /// <param name="value">Texture2D object to be drawn later on.</param>
        /// <param name="rectangle">the Rectangle on which the Texture2D is drawn.</param>
        public Texture(Texture2D value, Rectangle rectangle)
        {
            _value = value;

            _rectangle = rectangle;
        }
        #endregion 

        #region Constructor - Texture(Texture2D value, Rectangle rectangle, Color modulationColor)
        /// <summary>
        /// Creates a new Texture object with the given Texture2D object.
        /// </summary>
        /// <param name="value">Texture2D object to be drawn later on.</param>
        /// <param name="rectangle">the Rectangle on which the Texture2D is drawn.</param>
        /// <param name="modulationColor">the color used for modulation of the Texture2D</param>
        public Texture(Texture2D value, Rectangle rectangle, Color modulationColor)
        {
            _value = value;

            _rectangle = rectangle;

            _modulationColor = modulationColor;
        }
        #endregion 


        public int Width()
        {
            return (int)_rectangle.Right;
        }

        public int Height()
        {
            return (int)_rectangle.Bottom;
        }
    }
}
